import React from 'react'
import { Table, Modal } from 'antd'
import LwjTable from 'components/LwjTable/LwjTable'
import GeneralFilter from 'components/Filter/GeneralFilter'

const DistributorList = ({
                           tableProps,
                           dispatch,
                           ...distributorModalProps
                         }) => {
  /**
   * 定义筛选属性 表单相关
   * @type {{filterItems: *[], onFilterChange(*): void}}
   */
  const filterProps = {
    filterItems: [
      {
        type: 'input',
        id: 'name',
        title: '名称',
        placeholder: '门店名称'
      }
    ],
    onFilterChange (value) {
      dispatch({
        type: 'balanceChangeApply/distributorQuery',
        payload: {
          ...value
        }
      })
    }
  }

  const columns = [{
    title: '门店名称',
    dataIndex: 'organizationName',
    key: 'organizationName',
  }, {
    title: '门店编码',
    dataIndex: 'code',
    key: 'code',
  }]

  return (
    <div>
      <Modal {...distributorModalProps}>
        <GeneralFilter {...filterProps}/>
        <LwjTable
          {...tableProps}
          selectType="single"
          columns={columns}
        />
      </Modal>
    </div>
  )
}

export default DistributorList
